/****************************************************
          File Name:strftime.c
          Author: Abby Cin
          Mail: abbytsing@gmail.com
          Created Time: Tue 12 Aug 2014 11:49:59 AM CST
*****************************************************/

#include<stdio.h>
#include<stdlib.h>
#include<time.h>

int main(int argc,char *argv[])
{
    char outstr[200];
    time_t t;
    struct tm *tmp;

    t=time(NULL);
    tmp=localtime(&t);
    if(tmp==NULL)
    {
        perror("localtime");
        exit(EXIT_FAILURE);
    }

    if(strftime(outstr,sizeof(outstr),argv[1],tmp)==0)
    {
        fprintf(stderr,"strftime return 0");
        exit(EXIT_FAILURE);
    }

    printf("Time is: %s\n",outstr);
    exit(EXIT_SUCCESS);
}
